﻿@using System.Configuration
@{
    ViewBag.Title = "银行卡绑定";
    Layout = "~/Views/Shared/_LayoutFore.cshtml";

    ViewBag.SftAddress = ConfigurationManager.AppSettings["SftAddress"];
}

@section script{
    <script type="text/javascript">
        
        function QuShengFuTong() {
            //var sign = "merchantNo=" + $("#tzmerchantNo").val() + "&timestamp=temp&userName=" + $("#tzuserName").val();
            //sign = sign.replace(/\&/g, "|");
            //$.ajax({
            //    url: "/Account/GetSign2",
            //    type: "Post",
            //    success: function (data) {
            //        var time = data.substring(0, 14);
            //        var sign2 = data.substring(14, data.length);
            //        $("#tztimestamp").val(time);
            //        $("#tzsign").val(sign2);
            //        $("#formShouYe").submit();
            //    },
            //    data: "sign=" + sign,
            //});
            //window.open("http://wdtest.shengpay.com/user/card/manage.html");
        }
            ;
        (function (window, undefined, $) {
            $(document).ready(function () {
                // var mid = $('#hidMid').val();

                QuShengFuTong();
                var gridopt = {
                    url: options.listUrl,
                    colModel: [
                        { display: '编号', name: 'Id', width: "5%", sortable: true, hide: true, align: 'left', iskey: true },
                        { display: '会员编号', name: 'MemberId', width: "5%", sortable: true, hide: true, align: 'left' },
                        { display: '银行卡号', name: 'CardNO', width: "10%", sortable: false, align: 'left' },
                        { display: '持卡人姓名', name: 'CardName', width: "8%", sortable: false, align: 'left' },
                        { display: '银行卡名字', name: 'BankName', width: "14%", sortable: false, align: 'center' },
                        { display: '添加时间', name: 'AddTime', width: "14%", sortable: false, align: 'center' },
                        { display: '操作', name: 'Id', width: "14%", sortable: false, align: 'center', process: processOp }
                    ],
                    sortname: "Id",
                    sortorder: "DESC",
                    title: false,
                    rp: 5,
                    usepager: true,
                    showcheckbox: false
                };
                var xjgrid = new xjGrid("gridlist", gridopt);

                function processOp(value, cell) {
                    var ops = [];
                    ops.push("&nbsp;<a title='编辑' href='javascript:;'  onclick=\"util.Edit('", value, "')\"></i>编辑</a>");
                    ops.push("&nbsp;&nbsp;<a title='取消绑定' class='abtn' href='javascript:;'  onclick=\"util.Cancel('", value, "','", cell[1], "')\"><i class='fa fa-trash-o' ></i>取消绑定</a>");
                    return ops.join("");
                }
                $('#add').click(function () {
                    location.href = "/Account/BankCardAdd";
                });
                //取消绑定
                util.Cancel = function (id, name) {
                    $.dialog.confirm('你确定要取消吗？', function () {
                        $.post(options.cancelUrl + "/" + id, { id: id },
                            function (res) {
                                if (res.Status > 0) {
                                    $.dialog.tips(res.Message, 1, 'tips.gif', function () {
                                        xjgrid.Reload();
                                    });
                                } else {
                                    $.dialog.tips(res.Message);
                                }
                            },
                            "json"
                        );

                    });

                };
                //编辑
                util.Edit = function (id) {
                    location.href = "/Account/BankCardAdd" + "/" + id;
                }
            });
        })(window, undefined, jQuery);
        var util = {};
        var options = {
            listUrl: "@Url.Action("BankcardList", new { MemberId = ViewBag.Mid })",
            cancelUrl: "@Url.Action("BankCardDelete")"
        };
    </script>
}
  <form action="@ViewBag.SftAddress/index.html" method="POST" id="formShouYe" target="_blank">
               <input type="hidden" name="merchantNo" id="tzmerchantNo" value="@ViewBag.merchantNo"/>
                <input type="hidden" name="timestamp" id="tztimestamp" value="" />
                <input type="hidden" name="userName" id="tzuserName" value="@ViewBag.userName"/>
                <input type="hidden" name="sign" id="tzsign" value="" /> 
            </form>
<div class="RightContrent">
    <div style="margin-left: 50px; margin-right: 50px;">
        <div class="u-title">
            <h2>@ViewBag.Title</h2>
        </div>
        <div style="height: 2px; background-color: red;"></div>
        <div class="u-center">
            @*  <input type="hidden" name="ID" id="hidMid" value="@Model.ID" >*@
            <div class="menu-list" align="right">
                <input type="button" id="add" name="button" class="btn btn82 btn_save2" value="添加">
            </div> 
            <div class="line10"></div>
            <div id="gridlist">
            </div>
        </div>
    </div>
</div>
